home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / internet / weblibev / htmlpadp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-10-02  |  10.1 KB  |  336 lines

  1. { =============================================================================
  2.   Copyright 1995 by Potomac Software, Inc. Use of this material is subject to
  3.   the terms and conditions of the software license agreement.
  4.        
  5.   HTMLPADP.PAS: Contains Delphi declarations for WebLib (TM).         
  6.   ============================================================================== }
  7.  
  8. unit Htmlpars;
  9.  
  10. { ========== INTERFACE ========== }
  11.  
  12. interface
  13.     uses WinTypes;
  14.  
  15. { ========== Numeric identifiers for each HTML tag (tool developer note: these must 
  16.              remain in sync with internal lists stored in the DLL). ========== }
  17.              
  18. const 
  19.     HTML_INVALID = $0;
  20.     HTML_COMMENT = $1000;
  21.  
  22. { ========== Text style bits, returned by GetTextAttr ========== }
  23.  
  24. const
  25.     HTML_BOLD = $0000001;                    { <B>            (HTML 2.0) }
  26.     HTML_ITALIC    = $0000002;                    { <I> }
  27.     HTML_UNDERLINE = $0000004;                { <U> }
  28.     HTML_EMPHASIS = $0000008;                { <EM> }
  29.     HTML_STRONG = $0000010;                    { <STRONG> }
  30.     HTML_CITE = $0000020;                    { <CITE> }
  31.     HTML_CODE = $0000040;                    { <CODE> }
  32.     HTML_KEYBOARD = $0000080;                { <KBD> }
  33.     HTML_SAMPLE    = $0000100;                    { <SAMP> }
  34.     HTML_STRIKE    = $0000200;                    { <STRIKE> }
  35.     HTML_VARIABLE = $0000400;                { <VAR> }
  36.     HTML_TYPEWRITER = $0000800;                { <TT> }
  37.     HTML_LISTING = $0001000;                  { <LISTING> }
  38.     HTML_EXAMPLE = $0002000;                 { <XMP> }
  39.     HTML_PLAINTEXT = $0004000;                 { <PLAINTEXT> }
  40.     HTML_ARGUMENT = $0008000;                { <ARG>            (HTML+) }
  41.     HTML_DEFINE    = $0010000;                    { <DFN> }
  42.     HTML_ABBREV    = $0020000;                    { <ABBREV> }
  43.     HTML_COMMAND = $0040000;                 { <CMD> }
  44.     HTML_ACRONYM = $0080000;                { <ACRONYM> }
  45.     HTML_PERSON    = $0100000;                    { <PERSON> }
  46.     HTML_QUOTATION = $0200000;                { <Q> }
  47.     HTML_STRIKETHRU = $0400000;             { <S> }
  48.     HTML_SUBSCRIPT = $0800000;                 { <SUB> }
  49.     HTML_SUPERSCRIPT = $1000000;             { <SUP> }
  50.     HTML_BLINK = $2000000;                    { <BLINK>        (Netscape) }
  51.  
  52. { ========== Empty tags, returned by GetTagType ========== }
  53.  
  54. const
  55.     HTML_BASE = 1;                            { <BASE>        (HTML 2.0) }
  56.     HTML_ISINDEX = 2;                        { <ISINDEX> }
  57.     HTML_LINK = 3;                            { <LINK> }
  58.     HTML_NEXTID = 4;                        { <NEXTID> }
  59.     HTML_META = 5;                            { <META> }
  60.     HTML_BR = 6;                               { <BR> }
  61.     HTML_DD = 7;                            { <DD> }
  62.     HTML_DT = 8;                            { <DT> }
  63.     HTML_HR = 9;                            { <HR> }
  64.     HTML_IMG = 10;                            { <IMG> }
  65.     HTML_LI = 11;                            { <LI> }
  66.     HTML_P = 12;                            { <P> }
  67.     HTML_SELECT    = 13;                        { <SELECT>     }
  68.     HTML_INPUT = 14;                        { <INPUT> }
  69.     HTML_TEXTAREA = 15;                        { <TEXTAREA> }
  70.     HTML_OPTION    = 16;                        { <OPTION> }
  71.     HTML_TD = 17;                            { <TD>             (HTML+) }
  72.     HTML_TH = 18;                            { <TH> }
  73.     HTML_TR = 19;                            { <TR> }
  74.     HTML_RENDER = 20;                          { <RENDER> }
  75.     HTML_NOBR = 21;                            { <NOBR>        (Netscape) }
  76.     HTML_WBR = 22;                           { <WBR> }
  77.     HTML_BASEFONT = 23;                      { <BASEFONT>  }
  78.  
  79. { ========== Container Tags, returned by GetTagType ========== }
  80.  
  81. const
  82.     HTML_HTML = 257;                        { <HTML>        (HTML 2.0) }
  83.     HTML_HEAD = 258;                         { <HEAD> }
  84.     HTML_TITLE = 259;                          { <TITLE> }
  85.     HTML_A = 260;                            { <A> }
  86.     HTML_ADDRESS = 261;                       { <ADDRESS> }
  87.     HTML_BLOCKQUOTE = 262;                    { <BLOCKQUOTE> }
  88.     HTML_BODY = 263;                        { <BODY> }
  89.     HTML_DIR = 264;                            { <DIR> }
  90.     HTML_DL = 265;                            { <DL> }
  91.     HTML_H1 = 266;                            { <H1> }
  92.     HTML_H2 = 267;                           { <H2> }
  93.     HTML_H3 = 268;                           { <H3> }
  94.     HTML_H4 = 269;                          { <H4> }
  95.     HTML_H5 = 270;                           { <H5> }
  96.     HTML_H6 = 271;                           { <H6> }
  97.     HTML_MENU = 272;                           { <MENU> }
  98.     HTML_OL = 273;                          { <OL> }
  99.     HTML_PRE = 274;                           { <PRE> }
  100.     HTML_UL = 275;                           { <UL> }
  101.     HTML_FORM = 276;                           { <FORM> }
  102.     HTML_TABLE = 277;                       { <TABLE>        (HTML+) }
  103.     HTML_CAPTION = 278;                       { <CAPTION> }
  104.     HTML_ABSTRACT = 279;                       { <ABSTRACT> }
  105.     HTML_FIG = 280;                          { <FIG> }
  106.     HTML_FOOTNOTE = 281;                       { <FOOTNOTE> }
  107.     HTML_LIT = 282;                          { <LIT> }
  108.     HTML_MARGIN = 283;                       { <MARGIN> }
  109.     HTML_MATH = 284;                           { <MATH> }
  110.     HTML_ONLINE = 285;                       { <ONLINE> }
  111.     HTML_PRINTED = 286;                       { <PRINTED> }
  112.     HTML_NOTE = 287;                        { <NOTE> }
  113.     HTML_FONT = 288;                           { <FONT>        (Netscape) }
  114.     HTML_CENTER = 289;                       { <CENTER> }
  115.  
  116. { ========== Flags for ParseFile and ParseBuf ========== }
  117.  
  118. const
  119.     WL_KEEPATTRIBUTETAG    = $1;
  120.     WL_KEEPCLOSINGTAG = $2;
  121.  
  122. { ========== Flags for GetSibling ========== }
  123.  
  124. const
  125.     WL_FIRSTELEM = $1;
  126.     WL_NEXTELEM    = $2;
  127.     WL_PREVELEM    = $3;
  128.     WL_LASTELEM    = $4;
  129.  
  130. { ========== Flag for GetChild, Find and FindEnum to obtain root of parse tree ========== }
  131.  
  132. const
  133.     WL_ROOTELEMENT = 0;
  134.  
  135. { ========== Flags for GetElementType ========== }
  136.  
  137. const
  138.     WL_ROOT    = $0;
  139.     WL_TAG = $1;
  140.     WL_SPECIALCHAR = $2;
  141.     WL_COMMENT = $3;
  142.     WL_TEXT = $4;
  143.  
  144. { ========== Flags for GetTagAttrInfo ========== }
  145.  
  146. const
  147.     WL_WORD    = $1;
  148.     WL_QUOTEDSTRING = $2;
  149.     WL_NUMBER = $3;
  150.     WL_STANDALONE = $4;
  151.  
  152. { ========== Flags for EnumFindText, EnumFindSpecial, EnumFindComment & EnumFindTagName === }
  153.  
  154. const
  155.     WL_ENUMERATEALL    = 0;
  156.  
  157. { ========== Pre-defined enumeration notification messages included for convenience ===== }
  158.  
  159. const
  160.     WM_WEBLIB_ENUMPARSETREE    = 2001;
  161.     WM_WEBLIB_ENUMFINDTEXT = 2002;
  162.     WM_WEBLIB_ENUMFINDSPEC = 2003;
  163.     WM_WEBLIB_ENUMFINDCOMM = 2004;
  164.     WM_WEBLIB_ENUMFINDTAGTYPE = 2005;
  165.     WM_WEBLIB_ENUMFINDTAGNAME = 2006;
  166.     WM_WEBLIB_ENUMFINDTAGATTR = 2007;
  167.  
  168. { ========== Handles ========== }    
  169.  
  170. type
  171.     HPARSE = THandle;
  172.     HELEMENT = LongInt;
  173.     HTAGATTR = LongInt;
  174.  
  175. { ========== HTML API ========== }
  176.  
  177. function WLHtmlParseFile(lpszFilename: PChar;
  178.     wOptions: Word) : HPARSE; far;
  179.  
  180. function WLHtmlParseBuf(lpszBuf: PChar;
  181.     cbBuf: LongInt;
  182.     wOptions: Word) : HPARSE; far;
  183.  
  184. function WLHtmlEndParse(hParse: HPARSE) : Bool; far;
  185.  
  186. function WLHtmlEnumParseTree(hParse: HPARSE;
  187.     hwndNotify: HWnd;
  188.     nMsg: Word) : Bool; far;
  189.  
  190. function WLHtmlGetChild(hParse: HPARSE;
  191.     hElement: HELEMENT) : HELEMENT; far;
  192.  
  193. function WLHtmlGetParent(hParse: HPARSE;
  194.     hElement: HELEMENT) : HELEMENT; far;
  195.  
  196. function WLHtmlGetSibling(hParse: HPARSE;
  197.     hElement: HELEMENT;
  198.     wRel: Word) : HELEMENT; far;
  199.  
  200. function WLHtmlGetElementType(hParse: HPARSE;
  201.     hElement: HELEMENT) : Word; far;
  202.  
  203. function WLHtmlGetElementText(hParse: HPARSE;
  204.     hElement: HELEMENT) : pChar; far;
  205.  
  206. function WLHtmlGetTextAttr(hParse: HPARSE;
  207.     hElement: HELEMENT) : LongInt; far;
  208.  
  209. function WLHtmlGetTagName(hParse: HPARSE;
  210.     hElement: HELEMENT) : PChar; far;
  211.  
  212. function WLHtmlGetTagType(hParse: HPARSE;
  213.     hElement: HELEMENT) : Word; far;
  214.  
  215. function WLHtmlGetTagAttr(hParse: HPARSE;
  216.     hElement: HELEMENT;
  217.     hTagAttr: HTAGATTR;
  218.     var wType: Word;
  219.     lpszAttr: PChar;
  220.     cbAttr: Word;
  221.     lpszValue: PChar;
  222.     cbValue: Word) : HTAGATTR; far; 
  223.     
  224. function WLHtmlExtractTagAttr(hParse: HPARSE;
  225.     hElement: HELEMENT;
  226.     lpszAttr: pChar) : pChar; far;
  227.     
  228. function WLHtmlFindText(hParse: HPARSE;
  229.     hElement: HELEMENT;
  230.     lpszText: PChar) : HELEMENT; far;
  231.  
  232. function WLHtmlFindSpecial(hParse: HPARSE;
  233.     hElement: HELEMENT;
  234.     lpszSpecial: PChar) : HELEMENT; far;
  235.  
  236. function WLHtmlFindComment(hParse: HPARSE;
  237.     hElement: HELEMENT;
  238.     lpszCommentText: PChar) : HELEMENT; far;
  239.  
  240. function WLHtmlFindTagType(hParse: HPARSE;
  241.     hElement: HELEMENT;
  242.     nType: Word) : HELEMENT; far;
  243.  
  244. function WLHtmlFindTagName(hParse: HPARSE;
  245.     hElement: HELEMENT;
  246.     lpszTag: PChar) : HELEMENT; far;
  247.  
  248. function WLHtmlFindTagAttr(hParse: HPARSE;
  249.     hElement: HELEMENT;
  250.     nType: Word;
  251.     lpszAttr: PChar;
  252.     lpszValue: PChar) : HELEMENT; far;
  253.  
  254. function WLHtmlEnumFindText(hParse: HPARSE;
  255.     hElement: HELEMENT;
  256.     lpszText: PChar;
  257.     hwndNotify: HWnd;
  258.     nMsg: Word) : Bool; far;
  259.     
  260. function WLHtmlEnumFindSpecial(hParse: HPARSE;
  261.     hElement: HELEMENT;
  262.     lpszSpecial: PChar;
  263.     hwndNotify: HWnd;
  264.     nMsg: Word) : Bool; far;
  265.     
  266. function WLHtmlEnumFindComment(hParse: HPARSE;
  267.     hElement: HELEMENT;
  268.     lpszCommentText: PChar;
  269.     hwndNotify: HWnd;
  270.     nMsg: Word) : Bool; far;
  271.  
  272. function WLHtmlEnumFindTagType(hParse: HPARSE;
  273.     hElement: HELEMENT;
  274.     nType: Word;
  275.     hwndNotify: HWnd;
  276.     nMsg: Word) : Bool; far;
  277.     
  278. function WLHtmlEnumFindTagName(hParse: HPARSE;
  279.     hElement: HELEMENT;
  280.     lpszTag: PChar;
  281.     hwndNotify: HWnd;
  282.     nMsg: Word) : Bool; far;
  283.     
  284. function WLHtmlEnumFindTagAttr(hParse: HPARSE;
  285.     hElement: HELEMENT;
  286.     nType: Word;
  287.     lpszAttr: PChar;
  288.     lpszValueText: PChar;
  289.     hwndNotify: HWnd;
  290.     nMsg: Word) : Bool; far;
  291.     
  292. { ========== Utility function to parse URL ========== }
  293.  
  294. function WLParseAbsoluteURL(lpszURL: PChar;
  295.     lpszProtocol: PChar;
  296.     cbProtocol: Word;
  297.     lpszHost: PChar;
  298.     cbHost: Word;
  299.     var nPort: Word;
  300.     lpszPath: PChar;
  301.     cbPath: Word) : Bool; far;
  302.     
  303. { ========== IMPLEMENTATION ========== }
  304.  
  305. implementation 
  306.  
  307. function WLHtmlParseFile; external 'HTMLPARS';
  308. function WLHtmlParseBuf; external 'HTMLPARS';
  309. function WLHtmlEndParse; external 'HTMLPARS'; 
  310. function WLHtmlEnumParseTree; external 'HTMLPARS';
  311. function WLHtmlGetChild; external 'HTMLPARS';
  312. function WLHtmlGetParent; external 'HTMLPARS';
  313. function WLHtmlGetSibling; external 'HTMLPARS';
  314. function WLHtmlGetElementType; external 'HTMLPARS';
  315. function WLHtmlGetElementText; external 'HTMLPARS';
  316. function WLHtmlGetTextAttr; external 'HTMLPARS';
  317. function WLHtmlGetTagName; external 'HTMLPARS';
  318. function WLHtmlGetTagType; external 'HTMLPARS';
  319. function WLHtmlGetTagAttr; external 'HTMLPARS';
  320. function WLHtmlExtractTagAttr; external 'HTMLPARS';    
  321. function WLHtmlFindText; external 'HTMLPARS';
  322. function WLHtmlFindSpecial; external 'HTMLPARS';
  323. function WLHtmlFindComment; external 'HTMLPARS';
  324. function WLHtmlFindTagType; external 'HTMLPARS';
  325. function WLHtmlFindTagName; external 'HTMLPARS';
  326. function WLHtmlFindTagAttr; external 'HTMLPARS';
  327. function WLHtmlEnumFindText; external 'HTMLPARS';
  328. function WLHtmlEnumFindSpecial; external 'HTMLPARS';
  329. function WLHtmlEnumFindComment; external 'HTMLPARS';
  330. function WLHtmlEnumFindTagType; external 'HTMLPARS';
  331. function WLHtmlEnumFindTagName; external 'HTMLPARS';
  332. function WLHtmlEnumFindTagAttr; external 'HTMLPARS';
  333. function WLParseAbsoluteURL; external 'HTMLPARS';
  334.  
  335. end.
  336.